#pragma once

#define WM_SMNET_MSG_RECEIVED	(WM_USER + 0xf0)
#define WM_SMNET_MSG_CONNECTED		(WM_USER + 0xf1)
#define WM_SMNET_MSG_DISCONNECTED	(WM_USER + 0xf2)

#include "../../JMX_Library/bslib/netengine/netengine.h"

class CSMNet : public ISMNet
{
public:
	virtual BYTE StartSMNet(HWND hTargetWindow);
	virtual void CloseSMNet();

	virtual CMsg* NewMsg(WORD msg_id);
	virtual void  DelMsg(CMsg* pMsg);
	virtual bool  SendMsg(CMsg* pMsg);
	virtual bool  SendMsgToShardStartupServer(WORD nShardID,CMsg* pMsg);

	virtual void  EnableHeartBeat(bool bEnable){ m_bHeartBeat = bEnable;}
	virtual bool  IsEnableHeartBeat(){ return m_bHeartBeat;}

	virtual void  RecordActivity();
	virtual DWORD GetLastActivity();

	virtual DWORD GetCurrentConnectedSessionID(){ return m_dwSessionID;}

	virtual IBSNet*	GetNetEngine(){ return &m_NetEngine;}
	virtual DWORD GetSessionID(){ return m_dwSessionID;}

	virtual WORD  GetShardID(int nShardID);

protected:
	CNetEngine	m_NetEngine;
	CTask*		m_pMainTask;

	DWORD		m_dwSessionID;
	bool		m_bHeartBeat;

	DWORD		m_LastActivity;
};

extern CSMNet	g_SMNet;